<?php 
class homeClassAction extends Action
{
	

	/**
	*	首页数据
	*/
	public function homedataAction()
	{
		$nums 	= $this->get('nums');
		$allpid = $this->get('allpid');
		$loadci = (int)$this->get('loadci','0');
		$numa 	= explode(',', $nums);
		
		$itemdata 	= array();
		foreach($numa as $num){
			$act = ''.$num.'_data';
			if(method_exists($this, $act))$itemdata[$num] = $this->$act();
		}
		
		//加载角标
		$badge = array();

		return returnsuccess(array(
			'itemdata' 	=> $itemdata,
			'badge' 	=> $badge,
		));
	}
	
	//最新文件
	public function newfile_data()
	{
		$dbs   = m('word');
		$crows = $dbs->getworc($this->adminrs);
		$fqids = '0';
		foreach($crows as $k=>$rs){
			$fqids .= ','.$rs['id'].'';
		}
		return $dbs->getall('`fqid` in('.$fqids.') and `type`=0','filenum,fileext,filename,thumbpath,optdt', 'optdt desc limit 5');
	}
	
	
	//日志
	public function syslog_data()
	{
		return m('log')->getall('1=1','stype,level,remark,adddt', 'id desc limit 5');
	}
	
	//
	public function worc_data()
	{
		
		$data = array('已使用','未使用');
		
		
		$rows	= array();
		$crows  = m('word')->getworc($this->adminrs);
		foreach($crows as $k=>$rs){
			$sarr 	= array();
			$size 	= $rs['size'];
			if($size=='0')continue;
			$bili 	= floatval($rs['sizeu']) / floatval($rs['size']);
			$bili	= $bili*100;
			
			$sarr[] = array(
				'name' => '已使用',
				'biaoti'=> $rs['name'],
				'value' => $bili,
				'color' => getconfig('apptheme','#336699')
			);
			$sarr[] = array(
				'name' => '未使用',
				'value' => 100-$bili,
				'color' => '#cccccc'
			);
			$rows[] = $sarr;
		}
		return array(
			'rows' => $rows,
			'data' => $data,
		);
	}
	
	//分区
	public function fenqu_data()
	{
		$crows  = m('word')->getworc($this->adminrs);
		return $crows;
	}
	
	//分区统计
	public function worctj_data()
	{
		$crows  = m('word')->getworc($this->adminrs);
		return array(
			'crows' => $crows
		);
	}
}